package com.itheima.service;

import com.itheima.excption.MyException;
import com.itheima.pojo.UmsResourceCategory;
import com.itheima.vo.PageResultVo;
import com.itheima.vo.Result;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UmsResourceCategoryService {


    @DubboReference
    private UmsResourceCategoryApi umsResourceCategoryApi;

    /**
     * 添加后台资源分类
     * @param umsResourceCategory
     * @return
     */
    public void add(UmsResourceCategory umsResourceCategory) {

        boolean flag = umsResourceCategoryApi.add(umsResourceCategory);
        if (flag){
            throw new MyException("该名称已存在，请重试!");
        }
    }

    /**
     * 根据ID删除后台资源
     * @param id
     * @return
     */
    public void deleteByIds(Integer id) {
        umsResourceCategoryApi.deleteByIds(id);
    }

    /**
     * 查询所有后台资源分类
     * @return
     */
    public List<UmsResourceCategory> findAll() {
        List<UmsResourceCategory> list= umsResourceCategoryApi.findAll();
        return list;
    }

    /**
     * 修改后台资源分类
     * @param umsResourceCategory
     */
    public void update(Integer id,UmsResourceCategory umsResourceCategory) {
        umsResourceCategoryApi.update(id,umsResourceCategory);
    }


}
